﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class test4 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        int a = int.Parse(TextBox1.Text.ToString());
        int b = int.Parse(TextBox2.Text.ToString());
        int c = int.Parse(TextBox3.Text.ToString());
        string s = MyClass.S(a, b, c);
        Label3.Text = s;
    }
}
public class MyClass
{
    public static string S(int a,int b, int c)
    {
        double s= b * b - 4 * a * c,x1,x2;
        if (s == 0)
        {
            x1 = (-b + Math.Sqrt(s)) / (2 * a);
            x2 = (-b - Math.Sqrt(s)) / (2 * a);
            return "该方程有一个解，解为" + x1;
        }
        else if (s > 0)
        {
            x1 = (-b + Math.Sqrt(s)) / (2 * a);
            x2 = (-b - Math.Sqrt(s)) / (2 * a);
            return "该方程有两个解，分别为" + x1+","+x2;
        }
        else
            return "该方程无解";
    }
}